/*
 * @Author: xiaosihan
 * @Date: 2023-12-12 09:26:25
 * @Last Modified by: xiaosihan
 * @Last Modified time: 2024-10-31 01:13:58
 */

import largeScreenApi from '@api/largeScreenApi';
import axios from 'axios';
import { observable, configure } from 'mobx';

configure({ enforceActions: 'never' });

// 智慧检查数据
const doubtfulSituationStore = observable({
  //机构风险指数
  institutional_risk_index: [] as any,
  setInstitutional_risk_index(data: any) {
    this.institutional_risk_index = data;
  },

  //同单位同金额连续划卡
  institutional_repeat_consumption: {} as any,
  setInstitutional_repeat_consumption(data: any) {
    this.institutional_repeat_consumption = data;
  },
  //门诊小额个账连续划卡
  small_amount_repeat_consumption: {} as any,
  setSmall_amount_repeat_consumption(data: any) {
    this.small_amount_repeat_consumption = data;
  },

  //长监管数据筛查，五个模型轮播数据
  regulatory_model_List: [
    { model_name: '辅具适配异常模型', org_cnt: 10, psn_cnt: 4348, sum_cnt: 13001.0 },
    { model_name: '辅具适配异常模型', org_cnt: 10, psn_cnt: 4348, sum_cnt: 13001.0 },
    { model_name: '辅具适配异常模型', org_cnt: 10, psn_cnt: 4348, sum_cnt: 13001.0 },
    { model_name: '辅具适配异常模型', org_cnt: 10, psn_cnt: 4348, sum_cnt: 13001.0 },
    { model_name: '辅具适配异常模型', org_cnt: 10, psn_cnt: 4348, sum_cnt: 13001.0 },
    { model_name: '辅具适配异常模型', org_cnt: 10, psn_cnt: 4348, sum_cnt: 13001.0 },
  ],
  setRegulatory_model_List(data: any) {
    this.regulatory_model_List = data;
  },

  //模型检出分布情况
  risk_age_distribution: {} as any,
  setRisk_age_distribution(data: any) {
    this.risk_age_distribution = data;
  },
  //群体住院人员机构关系
  person_and_institutio_relation: [] as any,
  setPerson_and_institutio_relation(data: any) {
    this.person_and_institutio_relation = data;
  },
  //异常住院种类(同机构)
  abnormal_hospitalization_institutions: {} as any,
  setAbnormal_hospitalization_institutions(data: any) {
    this.abnormal_hospitalization_institutions = data;
  },
  //异常住院种类(跨机构)
  abnormal_hospitalization_different_institutions: {} as any,
  setAbnormal_hospitalization_different_institutions(data: any) {
    this.abnormal_hospitalization_different_institutions = data;
  },
  //异常住院种类(同家庭)
  abnormal_hospitalization_home: {} as any,
  setAbnormal_hospitalization_home(data: any) {
    this.abnormal_hospitalization_home = data;
  },
  // 四川地图统计
  sichuan_map_data_all: [] as any,
  sichuan_map_data: [] as any,
  setSichuan_map_data(data: any) {
    this.sichuan_map_data_all = data;
    this.sichuan_map_data = data;
  },
  mapActive: 2,
  setMapActive(active: number) {
    this.mapActive = active;
    let key = '';
    switch (active) {
      case 0:
        key = '医疗机构分析情况';
        break;
      case 1:
        key = '药店分析情况';
        break;
      case 2:
        key = '护理机构分析情况';
        break;
      case 3:
        key = '辅助器具机构分析情况';
        break;
    }
    const filterData = this.sichuan_map_data_all.filter((o: { fixmedins_type: string }) => o.fixmedins_type == key);
    let total = 0;
    filterData.forEach((o: { value: number }) => {
      total += o.value;
    });
    this.sichuan_map_data = filterData.map((o: any) => {
      return {
        ...o,
        adcode: Number(o.med_admdvs),
        total,
      };
    });
  },
  //地图统计
  map_statistics: {} as any,
  setMap_statistics(data: any) {
    this.map_statistics = data;
  },
  //地图数据
  map_data: [] as any,
  setMap_data(data: any) {
    this.map_data = data;
  },
  // 选中的地图数据
  activeMapData: [] as any,
  setActiveMap(data: any) {
    this.activeMapData = data;
  },
  // 左上风险总览数据
  Xdata: [] as any,
  setXdata(data: any) {
    this.Xdata = data;
  },
  // 异地监管数据
  remoteRegulatoryData: {} as any,
  setRemoteRegulatoryData(remoteRegulatoryData: any) {
    this.remoteRegulatoryData = remoteRegulatoryData;
  },

  //场景监控机构实时接入情况
  institutional_access_situation: [] as any,
  setInstitutional_access_situation(data: any) {
    this.institutional_access_situation = data;
  },
  //场景监控药店实时接入情况
  pharmacy_access_situation: [] as any,
  setPharmacy_access_situation(data: any) {
    this.pharmacy_access_situation = data;
  },
  //生物识别统计
  biometric_statistics: {} as any,
  setBiometric_statistics(data: any) {
    this.biometric_statistics = data;
  },
  //生物识别饼图数据
  biometric_classification_statistics: {} as any,
  setBiometric_classification_statistics(data: any) {
    this.biometric_classification_statistics = data;
  },
  //生物识别场景
  biometric_recognition_scenarios: {} as any,
  setBiometric_recognition_scenarios(data: any) {
    this.biometric_recognition_scenarios = data;
  },
});

//左上风险总览数据
axios.get('./intelligent_check/xData.json').then((res) => {
  doubtfulSituationStore.setXdata(res.data);
});

//机构风险指数
largeScreenApi.institutional_risk_index().then((res: any) => {
  doubtfulSituationStore.setInstitutional_risk_index(res.list);
});
// axios.get('./intelligent_check/institutional_risk_index.json').then((res) => {
//   doubtfulSituationStore.setInstitutional_risk_index(res.data);
// });

//同单位同金额连续划卡
axios.get('./intelligent_check/institutional_repeat_consumption.json').then((res) => {
  doubtfulSituationStore.setInstitutional_repeat_consumption(res.data);
});
//门诊小额个账连续划卡
axios.get('./intelligent_check/small_amount_repeat_consumption.json').then((res) => {
  doubtfulSituationStore.setSmall_amount_repeat_consumption(res.data);
});

//长监管数据筛查，五个模型轮播数据
largeScreenApi.check_risk_organizations().then((res: any) => {
  doubtfulSituationStore.setRegulatory_model_List(res.list);
});
// axios.get('./intelligent_check/regulatory_model_List.json').then((res) => {
//   doubtfulSituationStore.setRegulatory_model_List(res.data);
// });

//风险年龄分布
axios.get('./intelligent_check/risk_age_distribution.json').then((res) => {
  doubtfulSituationStore.setRisk_age_distribution(res.data);
});

//群体住院人员机构关系
// axios.get('./intelligent_check/person_and_institutio_relation.json').then((res) => {
//   doubtfulSituationStore.setPerson_and_institutio_relation(res.data);
// });
largeScreenApi.check_risk_organizations_list().then((res: any) => {
  doubtfulSituationStore.setPerson_and_institutio_relation(res.list);
});

//异常住院种类(同机构)
axios.get('./intelligent_check/abnormal_hospitalization_institutions.json').then((res) => {
  doubtfulSituationStore.setAbnormal_hospitalization_institutions(res.data);
});
//异常住院种类(跨机构)
axios.get('./intelligent_check/abnormal_hospitalization_different_institutions.json').then((res) => {
  doubtfulSituationStore.setAbnormal_hospitalization_different_institutions(res.data);
});
//异常住院种类(同家庭)
axios.get('./intelligent_check/abnormal_hospitalization_home.json').then((res) => {
  doubtfulSituationStore.setAbnormal_hospitalization_home(res.data);
});
// 四川地图统计
axios.get('./intelligent_check/sichuan_map_data.json').then((res) => {
  doubtfulSituationStore.setSichuan_map_data(res.data);
});
//地图统计
axios.get('./intelligent_check/map_statistics.json').then((res) => {
  doubtfulSituationStore.setMap_statistics(res.data);
});
//地图数据
// axios.get("./intelligent_check/map_data.json").then(res => {
//     doubtfulSituationStore.setMap_data(res.data);
// });
//场景监控机构实时接入情况
axios.get('./intelligent_check/institutional_access_situation.json').then((res) => {
  doubtfulSituationStore.setInstitutional_access_situation(res.data);
});
//场景监控药店实时接入情况
axios.get('./intelligent_check/pharmacy_access_situation.json').then((res) => {
  doubtfulSituationStore.setPharmacy_access_situation(res.data);
});
//场景监控药店实时接入情况
axios.get('./intelligent_check/remote_regulatory_data.json').then((res) => {
  doubtfulSituationStore.setRemoteRegulatoryData(res.data);
});
//生物识别统计
axios.get('./intelligent_check/biometric_statistics.json').then((res) => {
  doubtfulSituationStore.setBiometric_statistics(res.data);
});
//生物识别饼图数据
axios.get('./intelligent_check/biometric_classification_statistics.json').then((res) => {
  doubtfulSituationStore.setBiometric_classification_statistics(res.data);
});
//生物识别场景
axios.get('./intelligent_check/biometric_recognition_scenarios.json').then((res) => {
  doubtfulSituationStore.setBiometric_recognition_scenarios(res.data);
});
//风险总览
axios.get('./intelligent_check/risk_overview.json').then((res) => {
  doubtfulSituationStore.setActiveMap(res.data);
});

export default doubtfulSituationStore;
